<template>
	<view class="reset_pwd">
		<view class="form">
			<u--form labelPosition="top" :model="model1" :rules="rules" ref="uForm" labelWidth="200">
				<u-form-item label="原密码" prop="re_pwd" borderBottom ref="item1">
					<u--input placeholder="请输入原密码" v-model="model1.re_pwd" border="none"></u--input>
				</u-form-item>
				<u-form-item label="新密码" prop="userInfo.name" borderBottom ref="item1">
					<u--input placeholder="请输入新密码" v-model="model1.new_pwd" border="none"></u--input>
				</u-form-item>
			</u--form>
			<view class="submit">
				<u-button @click="reset">修改密码</u-button>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			model1: {
				re_pwd: '',
				new_pwd: ''
			},
			rules: []
		};
	},
	onLoad() {
		uni.setNavigationBarTitle({
			title: '修改密码'
		});
	},
	methods: {
		reset(){
			let _this = this
			_this.$http('user/reset',{
				..._this.model1
			}).then(res=>{
				if(res.code){
					uni.reLaunch({
						url:'/pages/login/login',
						success() {
							uni.clearStorage()
						}
					})
				}else{
					uni.$u.toast(res.msg)
				}
			})
		}
	}
};
</script>

<style lang="scss" scoped>
.form {
	padding: 0 30rpx;
}
.submit {
	margin-top: 50rpx;
}
</style>
